package jianzhiOffer;

public class num15 {
    public int hammingWeight(int n) {
        String num = Integer.toBinaryString(n);
        int len = num.length();
        int count = 0;
        for(int i = 0;i < len;i ++) {
            if(num.charAt(i) - 48 == 1) {
                count ++;
            }
        }
        return count;
    }
}
